package com.qf.news.service.impl;

import com.qf.news.domain.Admin;
import com.qf.news.domain.User;
import com.qf.news.mapper.AdminMapper;
import com.qf.news.mapper.UserMapper;
import com.qf.news.service.AdminService;
import com.qf.news.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;


@Service
@Transactional(rollbackFor = Exception.class)
public class UserServiceImpl implements UserService {
    @Resource
    UserMapper userMapper;

    @Override
    public User userlogin(String username, String password) {
        List<User> users = userMapper.selectByName(username);
        for (User user : users) {
            if (Objects.equals(password, user.getPassword())) {
                return user;
            }
        }
        return null;
    }
}
